package com.handydata.antifraud.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import com.handydata.common.convert.CommonBeanConvertor;
import com.handydata.common.web.AbsController;

import com.handydata.antifraud.common.exception.RejectProvinceBasedataExCode;
import com.handydata.antifraud.bo.rejectprovincebasedata.RejectProvinceBasedataReqBO;
import com.handydata.antifraud.bo.rejectprovincebasedata.RejectProvinceBasedataResBO;
import com.handydata.antifraud.vo.rejectprovincebasedata.CreateRejectProvinceBasedataReqVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.CreateRejectProvinceBasedataResVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.DeleteRejectProvinceBasedataReqVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.DeleteRejectProvinceBasedataResVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.ModifyRejectProvinceBasedataReqVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.ModifyRejectProvinceBasedataResVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.RejectProvinceBasedataBeanVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.QueryRejectProvinceBasedataReqVO;
import com.handydata.antifraud.vo.rejectprovincebasedata.QueryRejectProvinceBasedataResVO;
import com.handydata.antifraud.service.RejectProvinceBasedataService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;

@RequestMapping("/rejectprovincebasedata")
@RestController
public class RejectProvinceBasedataController extends AbsController {
	
	private static final Logger logger = LoggerFactory.getLogger(RejectProvinceBasedataController.class);
	
	@Autowired
	private RejectProvinceBasedataService rejectProvinceBasedataService;
	
	@ApiOperation(value="新增拒绝省份码表", notes="新增拒绝省份码表")
	@ApiImplicitParam(name = "req", value = "新增拒绝省份码表请求对象", required = true, dataType = "CreateRejectProvinceBasedataReqVO", paramType = "body")
	@PostMapping("/create")
	public CreateRejectProvinceBasedataResVO createRejectProvinceBasedata(@RequestBody CreateRejectProvinceBasedataReqVO req) {
		try {
			logger.info("Execute createRejectProvinceBasedata, param is {}", req);
			RejectProvinceBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectProvinceBasedataReqBO.class);
			RejectProvinceBasedataResBO resBO = rejectProvinceBasedataService.createRejectProvinceBasedata(reqBO);
			CreateRejectProvinceBasedataResVO res = CommonBeanConvertor.convert(resBO, CreateRejectProvinceBasedataResVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, CreateRejectProvinceBasedataResVO.class, req, RejectProvinceBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}

	@ApiOperation(value="修改拒绝省份码表", notes="修改拒绝省份码表")
	@ApiImplicitParam(name = "req", value = "修改拒绝省份码表请求对象", required = true, dataType = "ModifyRejectProvinceBasedataReqVO", paramType = "body")
	@PostMapping("/modify")
	public ModifyRejectProvinceBasedataResVO modifyRejectProvinceBasedata(@RequestBody ModifyRejectProvinceBasedataReqVO req) {
		try {
			logger.info("Execute modifyRejectProvinceBasedata, param is {}", req);
			RejectProvinceBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectProvinceBasedataReqBO.class);
			RejectProvinceBasedataResBO resBO = rejectProvinceBasedataService.modifyRejectProvinceBasedata(reqBO);
			ModifyRejectProvinceBasedataResVO res = CommonBeanConvertor.convert(resBO, ModifyRejectProvinceBasedataResVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, ModifyRejectProvinceBasedataResVO.class, req, RejectProvinceBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}

	@ApiOperation(value="删除拒绝省份码表", notes="删除拒绝省份码表")
	@ApiImplicitParam(name = "req", value = "修改拒绝省份码表请求对象", required = true, dataType = "DeleteRejectProvinceBasedataReqVO", paramType = "body")
	@PostMapping("/remove")
	public DeleteRejectProvinceBasedataResVO deleteRejectProvinceBasedata(@RequestBody DeleteRejectProvinceBasedataReqVO req) {
		try {
			logger.info("Execute deleteRejectProvinceBasedata, param is {}", req);
			RejectProvinceBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectProvinceBasedataReqBO.class);
			RejectProvinceBasedataResBO resBO = rejectProvinceBasedataService.deleteRejectProvinceBasedata(reqBO);
			DeleteRejectProvinceBasedataResVO res = CommonBeanConvertor.convert(resBO, DeleteRejectProvinceBasedataResVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, DeleteRejectProvinceBasedataResVO.class, req, RejectProvinceBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}
	
	@ApiOperation(value="查询拒绝省份码表", notes="查询拒绝省份码表")
	@ApiImplicitParam(name = "req", value = "查询拒绝省份码表请求对象", required = true, dataType = "QueryRejectProvinceBasedataReqVO", paramType = "body")
	@PostMapping("/query")
	public QueryRejectProvinceBasedataResVO queryRejectProvinceBasedata(@RequestBody QueryRejectProvinceBasedataReqVO req) {
		try {
			logger.info("Execute queryRejectProvinceBasedata, param is {}", req);
			RejectProvinceBasedataReqBO reqBO = CommonBeanConvertor.convert(req, RejectProvinceBasedataReqBO.class);
			RejectProvinceBasedataResBO resBO = rejectProvinceBasedataService.queryRejectProvinceBasedata(reqBO);
			QueryRejectProvinceBasedataResVO res = CommonBeanConvertor.convert(resBO, QueryRejectProvinceBasedataResVO.class, RejectProvinceBasedataBeanVO.class);
			return res;
		} catch (Exception e) {
			return handleException(e, QueryRejectProvinceBasedataResVO.class, req, RejectProvinceBasedataExCode.SYS_UNKNOWN_ERROR);
		}
	}
	
}
